package org.yonggan.dmp.tag

import java.sql.Connection

import org.apache.spark.sql.Row
import org.yonggan.dmp.utils.GeoHashEx

object BusinessTag extends Tag {

  /**
    * 用户 商圈标签
    *
    * @param agrs 0:row[Row]  1:matchPrec [Int] 匹配精度 2：java.sql.Connection
    * @return List[(String,Int)]  标签集合
    */
  override def makeTag(agrs: Any*): List[(String, Int)] = {

    val row = agrs(0).asInstanceOf[Row]
    val matchPrec = agrs(1).asInstanceOf[Int]
    val conn = agrs(1).asInstanceOf[Connection]
    // 提取经纬度
    val lnt =row.getAs[String]("long")
    val lat =row.getAs[String]("lat")

    // 转换未GeoHash
    val gecHash = GeoHashEx.enCode(lnt,lat)(12)
      // 匹配条件
    val str = gecHash.substring(0,matchPrec)+"*"

    val sql = ""
    val pstm = conn.prepareStatement("")

    pstm.setString(1,str)
    // 结果集
    val rs = pstm.executeQuery()



    null
  }
}
